<?php
/**
 * CONTENIDO extension pack (mpContenidoX), consists of multiple classes to
 * provide more features for Plugins/Modules.
 *
 * @package     mpContenidoX
 * @subpackage  Bootstrap
 * @author      Murat Purc <murat@purc.de>
 * @copyright   Copyright (c) 2008-2012 Murat Purc (http://www.purc.de)
 * @license     http://www.gnu.org/licenses/gpl-2.0.html - GNU General Public License, version 2
 * @version     $Id: mpBootstrap.class.php 21 2012-07-16 21:33:14Z purcaholic $
 */


defined('CON_FRAMEWORK') or die('Illegal call');


/**
 * Bootstrap class to prepare a CONTENIDO project for usage of mp* classes
 *
 * @package     mpContenidoX
 * @subpackage  Bootstrap
 * @author      Murat Purc <murat@purc.de>
 */
final class mpBootstrap
{

    /**
     * Self instance
     * @var  mpBootstrap
     */
    private static $_instance = null;


    /**
     * Invokes all functions required for bootstrapping
     *
     * @return  void
     */
    private function __construct()
    {
        $this->_initConstants();
        $this->_initIncludes();
        $this->_initAutoloader();
    }


    /**
     * Returns self instance (singleton)
     *
     * @return  mpBootstrap
     */
    public static function getInstance()
    {
        if (self::$_instance === null) {
            self::$_instance = new self();
        }
        return self::$_instance;
    }


    /**
     * Sets some constants
     *
     * @return  void
     */
    private function _initConstants()
    {
        define('MP_CLASSES_PATH', str_replace('\\', '/', dirname(__FILE__)));
    }


    /**
     * Includes required mp* files
     *
     * @return  void
     */
    private function _initIncludes()
    {
        require_once(MP_CLASSES_PATH . '/mpAutoload.class.php');
    }


    /**
     * Registers mpAutoloader
     *
     * @return  void
     */
    private function _initAutoloader()
    {
        spl_autoload_register(array('mpAutoload', 'autoload'));
    }

}